package com.admin.domain.modle;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.UUID;

import org.apache.commons.lang3.time.DateFormatUtils;

import com.admin.utils.OrderStatus;

/**
 * description 订单表 User: WeiDa Date: 2017-4-11 Time: 17:24
 */
public class Order implements Serializable {

    /**
     * 唯一资源
     */
    private String id = UUID.randomUUID().toString();

    /**
     * 演出ID(haiyin)
     */
    private Integer playId;
    /**
     * 订单ID(haiyin)
     */
    private Integer orderId;
    private String playName;
    private String playCode;
    private String playImage;
    /**
     * 演出时间
     */
    private String playDate;
    private String openId;
    private String nickName;
    private Integer quantity;
    private String status;
    private Double payAmount;
    private Date payTime;
    private String remark;
    //销售人员ID
    private String userId;

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    /**
     * 下单时间
     */
    private Date createTime;

    // 电话
    private String phone;

    // 姓名
    private String name;
    // 交易号(wechat)
    private String tradeNo;
    private List<OrderSeat> seats;

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Integer getOrderId() {
        return orderId;
    }

    public void setOrderId(Integer orderId) {
        this.orderId = orderId;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Integer getPlayId() {
        return playId;
    }

    public void setPlayId(Integer playId) {
        this.playId = playId;
    }

    public String getPlayName() {
        return playName;
    }

    public void setPlayName(String playName) {
        this.playName = playName;
    }

    public String getPlayCode() {
        return playCode;
    }

    public void setPlayCode(String playCode) {
        this.playCode = playCode;
    }

    public String getOpenId() {
        return openId;
    }

    public void setOpenId(String openId) {
        this.openId = openId;
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public Integer getQuantity() {
        return quantity;
    }

    public void setQuantity(Integer quantity) {
        this.quantity = quantity;
    }

    public String getStatus() {
        return status;
    }

    public String getFormatStatus() {
        return OrderStatus.valueOf(status).getDesc();
    }

    public String getFormatAction() {
        OrderStatus os = OrderStatus.valueOf(status);
        if (os == OrderStatus.INIT) {
            return "/wechat/payment/" + orderId;
        } else if (os == OrderStatus.PRE) {
            return "/wechat/order/" + orderId;
        } else if (os == OrderStatus.PAID){
            return "/wechat/order/" + orderId;
        }else {
            return "javascript:;";
        }
    }

    public String getFormatActionDesc() {
        OrderStatus os = OrderStatus.valueOf(status);
        if (os == OrderStatus.INIT) {
            return "立即付款";
        } else if (os == OrderStatus.PRE) {
            return "完善信息";
        } else if (os == OrderStatus.PAID) {
            return "取票码";
        } else if (os == OrderStatus.VERIFIED) {
            return "删除订单";
        } else {
            return "";
        }
    }

    public boolean getHasPaid() {
        OrderStatus os = OrderStatus.valueOf(status);
        return os.ordinal() >= OrderStatus.PAID.ordinal();
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public Double getPayAmount() {
        return payAmount;
    }

    public void setPayAmount(Double payAmount) {
        this.payAmount = payAmount;
    }

    public Date getPayTime() {
        return payTime;
    }

    public void setPayTime(Date payTime) {
        this.payTime = payTime;
    }

    public String getPlayDate() {
        return playDate;
    }

    public void setPlayDate(String playDate) {
        this.playDate = playDate;
    }

    public String getTradeNo() {
        return tradeNo;
    }

    public void setTradeNo(String tradeNo) {
        this.tradeNo = tradeNo;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public String getFormatCreateTime() {
        return DateFormatUtils.format(createTime, "yyyy-MM-dd hh:mm:ss");
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<OrderSeat> getSeats() {
        return seats;
    }

    public void setSeats(List<OrderSeat> seats) {
        this.seats = seats;
    }

    public String getPlayImage() {
        return playImage;
    }

    public void setPlayImage(String playImage) {
        this.playImage = playImage;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o)
            return true;
        if (o == null || getClass() != o.getClass())
            return false;

        Order order = (Order) o;

        return id != null ? id.equals(order.id) : order.id == null;

    }

    @Override
    public int hashCode() {
        return id != null ? id.hashCode() : 0;
    }
}
